#SOC_NAME="icesugar_pro"
SOC_NAME=$1
#CORES_DIR="/home/hemin/icesugar-pro-litex/litex/litex/soc/cores"
CORES_DIR=$2

DOC_USB=$3
DOC_AES=$4
DOC_RTC=$5
DOC_IIC=$6
DOC_IRDA=$7

echo $DOC_USB
echo $DOC_AES
echo $DOC_RTC
echo $DOC_IIC
echo $DOC_IRDA

if [ "$3" == "yes" ]; then
	cp $CORES_DIR/usb_ohci.rst ./build/$SOC_NAME/doc/ -f
	sed -i '/Indices and tables/i\    usb_ohci' ./build/$SOC_NAME/doc/index.rst
fi

if [ "$4" == "yes" ]; then
	cp ./AES128_192/aes128.rst ./build/$SOC_NAME/doc/ -f 
	sed -i '/Indices and tables/i\    aes128' ./build/$SOC_NAME/doc/index.rst
fi

if [ "$5" == "yes" ]; then
	cp ./RTC_WB/*.jpg ./build/$SOC_NAME/doc/ -f 
	cp ./RTC_WB/rtc.rst ./build/$SOC_NAME/doc/ -f 
	sed -i '/Indices and tables/i\    rtc' ./build/$SOC_NAME/doc/index.rst
fi

if [ "$6" == "yes" ]; then
	cp ./IIC_WB/iic.rst ./build/$SOC_NAME/doc/ -f 
	sed -i '/Indices and tables/i\    iic' ./build/$SOC_NAME/doc/index.rst
fi

if [ "$7" == "yes" ]; then
	cp ./IRDA_WB/irda.rst ./build/$SOC_NAME/doc/ -f 
	sed -i '/Indices and tables/i\    irda' ./build/$SOC_NAME/doc/index.rst
fi

sed -i '/Indices and tables/i\    ' ./build/$SOC_NAME/doc/index.rst

